package cc.vv.btpartyjob.homepage.delegate

import android.support.v4.view.ViewPager
import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.homepage.R
import cc.vv.btpartyjob.jnimodule.adapter.JniViewPageAdapter
import cc.vv.mvp.delegate.BaseAppDelegate

/**
 * 学习排名托管类
 * Created by Chen.qi on 2018/10/24.
 */
class LearnRankActivityDelegate : BaseAppDelegate() {

    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_learn_rank_all
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleTopBar(title: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_rank_Tab_top_bar)
        titleBar?.setTitle(title)
    }

    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_rank_Tab_top_bar)
        titleBar?.setEventInterface(event)
    }


    /**
     * 设置adatper
     */
    fun setAdapterData(adapter: JniViewPageAdapter) {
        getView<ViewPager>(R.id.vp_alr_container)?.adapter = adapter
    }

    /**
     * 设置viewpager位置
     */
    fun setViewPagerPos(currentPos: Int) {
        getView<ViewPager>(R.id.vp_alr_container)?.currentItem = currentPos

    }

    /**
     * 设置viewPager的监听
     */
    fun bindViewPagerLisener(listener: ViewPager.OnPageChangeListener) {
        getView<ViewPager>(R.id.vp_alr_container)?.addOnPageChangeListener(listener)
    }

    /**
     * 设置排名
     */
    fun setBackGr(type: Int?) {
        val leftView = getView<TextView>(R.id.tv_alr_left)
        val rightView = getView<TextView>(R.id.tv_alr_right)

        if (type == 0) {
            leftView?.isSelected = true
            rightView?.isSelected = false
            leftView?.setBackgroundResource(R.mipmap.icon_rank_table)
            rightView?.setBackgroundResource(0)
        } else {
            rightView?.isSelected = true
            leftView?.isSelected = false
            rightView?.setBackgroundResource(R.mipmap.icon_rank_table)
            leftView?.setBackgroundResource(0)
        }
    }


}